#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define OJ_TEST 0
#define LOCAL_TEST 0

#define M 901

static int max(int a, int b){ return a>b?a:b; }
static int min(int a, int b) { return a<b?a:b; }

char num[128];
int palindrome(const char *s){
	int i, j;
	for(i=0, j=strlen(s)-1; i<j; ++i, --j){
		if(s[i]!=s[j]) return 0;
	}
	return 1;
}
void reverse_add(char *s){
	static char backup[128];
	int i,j, n, c, tot;
	n = strlen(s); c=0;
	for(i=0; i<n; ++i){
		tot = s[i]-'0' + s[n-i-1]-'0' + c;
		c = tot/10;
		backup[i] = tot%10 + '0';
	}
	if(c) backup[i++]=c+'0';
	for(--i, j=0; i>=0; ++j, --i){
		s[j] = backup[i];
	}
	s[j] = 0;
}
static void solve(void){
	int cs, nr;
	for(scanf("%d", &cs); cs>0; --cs){
		scanf("%s", num);
		nr=0;
		do{
			reverse_add(num);
			++nr;
		}while(!palindrome(num));
		printf("%d %s\n", nr, num);
	}

}
#if OJ_TEST
	int main(int ac, char *av[]){
		solve();
		return 0;
	}
#elif  LOCAL_TEST
	void run(void){
		solve();
	}

#else

#endif
